CREATE TABLE [dbo].[tb_ServiciosAgentes]
(
[idServicioAgente] [int] NOT NULL IDENTITY(1, 1),
[Agente] [int] NULL,
[NroDeOrden9] [int] NULL,
[CargoSalarial] [int] NULL,
[Asignatura] [int] NULL,
[Horas] [int] NULL,
[UbicacionOrig] [int] NULL,
[SituacionRevista] [int] NULL,
[FechaAlta] [datetime] NULL,
[Baja] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[FechaBaja] [datetime] NULL,
[FechaTermino] [datetime] NULL,
[NormaAlta] [int] NULL,
[NormaBaja] [int] NULL,
[CausaAlta] [int] NULL,
[CausaBaja] [int] NULL,
[Liquida] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[TipoDeServicio] [int] NULL,
[Sistema] [int] NULL,
[RegimenLaboral] [int] NULL,
[Financiamiento] [int] NULL,
[Presupuesto] [int] NULL,
[Finalidad] [int] NULL,
[TipoDeFuncion] [int] NULL,
[RegimenSalarial] [int] NULL,
[RegimenDesignacion] [int] NULL,
[LegajoSalarial] [int] NULL,
[ClavePSalarial] [int] NULL,
[EstadoLiqExt] [int] NOT NULL,
[Vacante] [int] NULL,
[ServicioLigado] [int] NULL,
[ServicioQueSuple] [int] NULL,
[CategoriaTitulo] [int] NULL,
[EstaEnProcesoDeTitularizacion] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CuentaAcumulacion] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[EsIncremHoras] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ServicioAnterior] [int] NULL,
[idServicioNuevo] [int] NULL,
[NormaAltaAnteriores] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[NormaBajaAnteriores] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ObservacionesSARRHH] [varchar] (90) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ObservacionesSARRHH_LH] [varchar] (90) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Agrupamiento] [int] NULL,
[SubOrganizacion] [int] NULL,
[Transferido] [int] NULL,
[Edificio] [int] NULL,
[conciliado] [bit] NULL,
[fechaConciliacion] [date] NULL,
[ultimaInconsistencia] [int] NULL
) ON [PRIMARY]
GO
GRANT UPDATE ON  [dbo].[tb_ServiciosAgentes] TO [conciliacion]
GO

ALTER TABLE [dbo].[tb_ServiciosAgentes] ADD CONSTRAINT [PK_tb_ServiciosAgentes_1] PRIMARY KEY CLUSTERED  ([idServicioAgente]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [idx_Agente] ON [dbo].[tb_ServiciosAgentes] ([Agente]) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [PK_tb_ServiciosAgentes] ON [dbo].[tb_ServiciosAgentes] ([idServicioAgente]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] ADD CONSTRAINT [fk_tb_ServiciosAgentes_tb_Agrupamiento] FOREIGN KEY ([Agrupamiento]) REFERENCES [dbo].[tb_Agrupamiento] ([idAgrupamiento])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_Asignaturas] FOREIGN KEY ([Asignatura]) REFERENCES [dbo].[tb_Asignaturas] ([idAsignatura])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_CargosSalariales] FOREIGN KEY ([CargoSalarial]) REFERENCES [dbo].[tb_CargosSalariales] ([idCargo])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_CategoriasDeTitulo] FOREIGN KEY ([CategoriaTitulo]) REFERENCES [dbo].[tb_CategoriasDeTitulo] ([idCategoria])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_CausasAltas] FOREIGN KEY ([CausaAlta]) REFERENCES [dbo].[tb_CausasAltas] ([idCausaAlta])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_CausasBajas] FOREIGN KEY ([CausaBaja]) REFERENCES [dbo].[tb_CausasBajas] ([idCausaBaja])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] ADD CONSTRAINT [fk_tb_Suborganizaciones_tb_Edificio] FOREIGN KEY ([Edificio]) REFERENCES [dbo].[tb_Edificios] ([idEdificio])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_EstadoLiquidacionExterna] FOREIGN KEY ([EstadoLiqExt]) REFERENCES [dbo].[tb_EstadoLiquidacionExterna] ([idEstadoLiquidacion])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_Finalidades] FOREIGN KEY ([Finalidad]) REFERENCES [dbo].[tb_Finalidades] ([idFinalidad])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_FuentesDeFinanciamiento] FOREIGN KEY ([Financiamiento]) REFERENCES [dbo].[tb_FuentesDeFinanciamiento] ([idFuenteFinanciamiento])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_PartidasPresupuestarias] FOREIGN KEY ([Presupuesto]) REFERENCES [dbo].[tb_PartidasPresupuestarias] ([idPartida])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_RegimenDesignaciones] FOREIGN KEY ([RegimenDesignacion]) REFERENCES [dbo].[tb_RegimenDesignaciones] ([idRegimenDesignacion])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_RegimenLaboral] FOREIGN KEY ([RegimenLaboral]) REFERENCES [dbo].[tb_RegimenLaboral] ([idRegimenLaboral])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_RegimenSalarial] FOREIGN KEY ([RegimenSalarial]) REFERENCES [dbo].[tb_RegimenSalarial] ([idRegimenSalarial])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_ServiciosAgentes] FOREIGN KEY ([ServicioLigado]) REFERENCES [dbo].[tb_ServiciosAgentes] ([idServicioAgente])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_Sistemas] FOREIGN KEY ([Sistema]) REFERENCES [dbo].[tb_Sistemas] ([idSistema])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_SituacionRevista] FOREIGN KEY ([SituacionRevista]) REFERENCES [dbo].[tb_SituacionRevista] ([idSituacionRevista])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] ADD CONSTRAINT [fk_tb_ServiciosAgentes_tb_Suborganizaciones] FOREIGN KEY ([SubOrganizacion]) REFERENCES [dbo].[tb_SubOrganizaciones] ([idSubOrganizacion])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_TiposDeFuncion] FOREIGN KEY ([TipoDeFuncion]) REFERENCES [dbo].[tb_TiposDeFuncion] ([idTipoFuncion])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_TiposDeServicio] FOREIGN KEY ([TipoDeServicio]) REFERENCES [dbo].[tb_TiposDeServicio] ([idTipoServicio])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_Organizaciones] FOREIGN KEY ([UbicacionOrig]) REFERENCES [dbo].[tb_Organizaciones] ([idOrganizaciones])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_Inconsistencia] FOREIGN KEY ([ultimaInconsistencia]) REFERENCES [dbo].[tb_Inconsistencia] ([idInconsistencia])
GO
ALTER TABLE [dbo].[tb_ServiciosAgentes] WITH NOCHECK ADD CONSTRAINT [FK_tb_ServiciosAgentes_tb_Vacantes] FOREIGN KEY ([Vacante]) REFERENCES [dbo].[tb_Vacantes] ([idVacante])
GO
